package test2;


public class Course {
	private String courseName;
	private int courseId;
	private Teacher teacher;
	private Student[] students;
	private String coursePlace;
	private String couseTime;
	//构造函数
	public Course(int courseId,String courseName,String coursePlace,String couseTime,Teacher teacher) {
	  super();
	  this.courseId=courseId;
	  this.courseName=courseName;
	  this.setTeacher(teacher);
	  this.coursePlace=coursePlace;
	  this.couseTime = couseTime;
	  students = new Student[30];
	 }
	public Course(int courseId,String courseName,String coursePlace,Teacher teacher) {
	 super();
	 this.courseId=courseId;
	 this.courseName=courseName;
	 this.setTeacher(teacher);
	 this.coursePlace =coursePlace;
	 students = new Student[30];
	}
	public Course(int courseId,String courseName,float credit) {
	 super();
	 this.courseId=courseId;
	 this.courseName=courseName;
	 students = new Student[30];
	}

	public Course(int courseId,String courseName) {
	 super();
	 this.courseId=courseId;
	 this.courseName=courseName;
	 students = new Student[30];
	}

	public Course() {
	 super();
	 students = new Student[30];
	}

	
	public void setId(int id){
	 this.courseId=id;
	}
	public int getId(){
	 return this.courseId;
	}
	public void setName(String name){
	 this.courseName=name;
	}
	public String getName(){
	 return this.courseName;
	}

	public Teacher getTeacher() {
	 return teacher;
	}
	public void setTeacher(Teacher teacher) {
	 this.teacher = teacher;
	}

	
		public boolean addStudent(Student stu){
			boolean flag = false;//
			if(!isSelectedStudent(stu)&&isNullStudent(stu)){
					for(int i=0;i<students.length;i++){
						if(students[i]==null){
							students[i]=stu;
							flag=true;
							break;
						}
					}
		 return flag;
		}
			return flag;
		}
	private boolean isNullStudent(Student stu) {
		
		return false;
	}
	
	    public boolean removeStudent1(Student stu){
	    	boolean flag = false;
	    	if(isSelectedStudent(stu)){//选过这门课
	    		for(int i=0;i<students.length;i++){
	    			if(students[i] == stu){
	    				students[i] = null;
	    				flag = true;
	    				break;
					}
				}
		 return flag;
		}
			return flag;
	    }
	 private boolean isSelectedStudent(Student stu) {
	
		return false;
	}
	
		public void displayStudent(){
			System.out.println("选择的课程："+this.courseName+"的学生有:");
			for(Student s:students){
				if(s!=null){
					System.out.print(s.getStuName()+" ");
					}
				}
			System.out.println();
			}
		public void addStudent1(test2.Student student) {
			
			
		}
		public void removeStudent(test2.Student student) {
			
			
		}
	}
